package com.yinhe.music.yhmusic.widget;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 *
 * @author hasee
 * @date 2017/8/29
 */

public class SpaceDecoration extends RecyclerView.ItemDecoration {
    private int left;
    private int right;
    private int top;
    private int bottom;

    public SpaceDecoration(Context context, int left, int right, int top, int bottom) {
        this.left = (int) (left * context.getResources().getDisplayMetrics().density);
        this.top = (int) (top * context.getResources().getDisplayMetrics().density);
        this.right = (int) (right * context.getResources().getDisplayMetrics().density);
        this.bottom = (int) (bottom * context.getResources().getDisplayMetrics().density);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {
        outRect.set(left, top, right, bottom);
    }
}
